package com.guoyh.baseutils.utils

import android.content.res.AssetManager
import com.blankj.utilcode.util.Utils
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.lang.StringBuilder

/**
 * @CreateDate: 2021/8/25 1:40 下午
 * @Author: guoyh
 * @Description: java类作用描述
 */
object AssetsUtil {

    fun getJson(fileName:String):String{
        val stringBuilder = StringBuilder()
        try {
            val assetManager: AssetManager = Utils.getApp().getAssets()
            val bf = BufferedReader(
                InputStreamReader(
                    assetManager.open(fileName)
                )
            )
            var line: String?
            while (bf.readLine().also { line = it } != null) {
                stringBuilder.append(line)
            }
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return stringBuilder.toString()
    }
}